<%@ page language="java" import="weaver.conn.RecordSet" pageEncoding="UTF-8"%>
<%@page import="weaver.general.Util"%>
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%
    ResourceComInfo resourceComInfo = new ResourceComInfo();
    String requestid = Util.null2String(request.getParameter("requestid"));
    String hideczlx = Util.null2String(request.getParameter("hideczlx"),"0");
    RecordSet rs = new RecordSet();
    RecordSet rs1 = new RecordSet();

%>
<%!
    private String removeHtml(String str){
        String temp = "";
        while(str.indexOf("<")>=0){
            int index = str.indexOf("<");
            temp += str.substring(0,index);
            str = str.substring(index+1);
            index = str.indexOf(">");
            str = str.substring(index+1);
        }
        temp += str;
        return temp;
    }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <SCRIPT language="javascript" src="/js/weaver_wev8.js"></script>
    <SCRIPT language="javascript" src="/js/weaverTable_wev8.js"></script>
    <SCRIPT type="text/javascript" src="/formmode/js/WdatePicker/WdatePicker_wev8.js"></script>
    <LINK REL=stylesheet type=text/css HREF=/css/Weaver_wev8.css>
    <link href="/formmode/css/formmode_wev8.css" type="text/css" rel="stylesheet" />
    <script language=javascript src="/wui/common/jquery/plugin/Listener_wev8.js"></script>
    <SCRIPT type="text/javascript" src="/js/workflow/VCEventHandle_wev8.js"></SCRIPT>
    <script src='echarts.min.js'></script>
    <script src='macarons.js'></script>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
            border: 0;
            list-style-type: none;
            font-size: 14px!important;
            font-family: "Microsoft YaHei"!important;
        }
        td,th{
            border-bottom: 1px solid white;
            border-right: 1px solid white;
            height: 30px;
            text-align: center;
        }
        th{
            font-weight: bold;
        }
    </style>
</head>

<body>
<table style="width:100%;" border="0" cellpadding="0" cellspacing="0">
    <tr style="width: 100%;background-color: #4394da;color: white;">
        <th style="width: 4%;border-left: 1px solid white;border-top: 1px solid white;">序号</th>
        <th style="width: 10%;border-top: 1px solid white;">步骤</th>
        <th style="width: 10%;border-top: 1px solid white;">上一步操作人</th>
        <th style="width: 10%;border-top: 1px solid white;">处理人员</th>
        <%if(hideczlx.equals("1")){ %><th style="width: 10%;border-top: 1px solid white;">处理方式</th><%} %>
        <th style="width: 15%;border-top: 1px solid white;">收到时间</th>
        <th style="width: 15%;border-top: 1px solid white;">处理时间</th>
        <th style="width: 30%;border-top: 1px solid white;">处理意见</th>
    </tr>
    <%
        rs.executeQuery( "select t.operator,t.nodeid,t1.nodename,t.receivedpersonids,t.remark," +
                " t.logtype,t1.isstart,t.operatedate,t.operatetime from workflow_requestlog t " +
                " left join workflow_nodebase t1 on t.nodeid=t1.id " +
                "where t.requestid='"+requestid+"' and t.logtype !='9'" +
                " order by t.nodeid,t.operatedate,t.operatetime" );
        int index = 0;
        while(rs.next()){
            String lastoperator = Util.null2String(rs.getString("operator"));
            String nodeid = Util.null2String(rs.getString("nodeid"));
            String nodename = Util.null2String(rs.getString("nodename"));
            String receivedpersonids = Util.null2String(rs.getString("receivedpersonids"));
            String logtype = Util.null2String(rs.getString("logtype"));
            String isstart = Util.null2String(rs.getString("isstart"));
            if("1".equals(isstart)){
                String remark = Util.null2String(rs.getString("remark"));
                String operatedate = Util.null2String(rs.getString("operatedate"));
                String operatetime = Util.null2String(rs.getString("operatetime"));
                remark = removeHtml(remark);
                if(remark.equals("")){
                    remark = "<span style='color:gray;'>[未签署]</span>";
                }
                index++;
    %>
    <tr style="<%=index%2==0?"background-color: #f5f5f5;":"" %>">
        <td style="border-left: 1px solid white;"><%=index %></td>
        <td nodeid="<%=nodeid %>"><%=nodename %></td>
        <td operator="<%=lastoperator %>"><%="" %></td>
        <td userid="<%=lastoperator %>"><%=resourceComInfo.getLastname(lastoperator) %></td>
        <td><%=" "%></td>
        <td><%=operatedate+" "+operatetime %></td>
        <td style="text-align: left;"><%=remark %></td>
    </tr>
    <%
            }
            String[] strs = receivedpersonids.split( "," );
            for (String handloperator:strs) {
                String userid = "1".equals(isstart)?lastoperator:handloperator;
                rs1.executeQuery( "select remark from workflow_requestlog  where requestid=? " +
                        "and operator=? and nodeid=? ",requestid,handloperator,nodeid);
                rs1.next();
                String remark = Util.null2String( rs1.getString( "remark" ) );
                rs1.executeQuery( "select receivedate,receivetime,operatedate,operatetime " +
                        "from workflow_currentoperator where requestid=? and userid=? and nodeid=?",requestid,userid,nodeid);
                rs1.next();
                String receivedate = Util.null2String( rs1.getString( "receivedate" ) );
                String receivetime = Util.null2String( rs1.getString( "receivetime" ) );
                String operatedate = Util.null2String( rs1.getString( "operatedate" ) );
                String operatetime = Util.null2String( rs1.getString( "operatetime" ) );
                remark = removeHtml(remark);
                if(remark.equals("")){
                    remark = "<span style='color:gray;'>[未签署]</span>";
                }
                index++;

    %>
    <tr style="<%=index%2==0?"background-color: #f5f5f5;":"" %>">
        <td style="border-left: 1px solid white;"><%=index %></td>
        <td nodeid="<%=nodeid %>"><%=nodename %></td>
        <td operator="<%=lastoperator %>"><%=resourceComInfo.getLastname(lastoperator) %></td>
        <td userid="<%=handloperator %>"><%=resourceComInfo.getLastname(handloperator) %></td>
        <td><%=receivedate+" "+receivetime %></td>
        <td><%=operatedate+" "+operatetime %></td>
        <td style="text-align: left;"><%=remark %></td>
    </tr>
    <%
            }
        }
    %>
</table>
</body>
</html>
